home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 October / Macformat17.cdr / Shareware City / Developers / WASTETCL / C Interfaces / WASTE.h < prev   
Encoding:
C/C++ Source or Header  |  1994-05-15  |  7.1 KB  |  242 lines  |  [TEXT/R*ch]

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C interface to the WASTE text engine
  5.  *    version 1.0a3 -- March/April 1994
  6.  *
  7.  *    Copyright (c) 1993-1994 Merzwaren
  8.  *    All Rights Reserved
  9.  *
  10.  *  Changed LongCoords stuff as in LongCoords.h
  11.  */
  12.  
  13. #ifndef _WASTE_
  14. #define _WASTE_
  15.  
  16. #ifndef _LongCoords_
  17. #ifndef __LONGCOORDINATES__
  18. #include "LongCoords.h"
  19. #endif
  20. #endif
  21.  
  22. #ifndef __TEXTEDIT__
  23. #include <TextEdit.h>
  24. #endif
  25.  
  26. /*    alignment styles */
  27.  
  28. enum {
  29.     weFlushLeft         =    -2,        /* flush left */
  30.     weFlushRight        =    -1,        /* flush right */
  31.     weFlushDefault        =     0,        /* flush according to system direction */
  32.     weCenter            =     1,        /* centered */
  33.     weJustify            =     2        /* fully justified */
  34. };
  35.  
  36. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  37.  
  38. enum {
  39.     weDoFont            =    0x0001,
  40.     weDoFace            =    0x0002,
  41.     weDoSize            =    0x0004,
  42.     weDoColor            =    0x0008,
  43.     weDoAll                =    weDoFont + weDoFace + weDoSize + weDoColor,
  44.     weDoAddSize            =    0x0010,
  45.     weDoToggleFace        =    0x0020,
  46.     weDoReplaceFace        =    0x0040
  47. };
  48.  
  49. /*    values for the edge parameter in WEGetOffset etc. */
  50.  
  51. enum {
  52.     kLeadingEdge = -1,
  53.     kTrailingEdge = 0
  54. };
  55.  
  56. /*    values for WEFeatureFlag feature parameter */
  57.  
  58. enum {
  59.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  60.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  61.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  62.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  63.     weFDrawOffscreen    =    11        /* draw text offscreen for smoother visual results */
  64. };
  65.  
  66. /*    values for WENew flags parameter */
  67.  
  68. enum {
  69.     weDoAutoScroll        =    1 << weFAutoScroll,
  70.     weDoOutlineHilite    =    1 << weFOutlineHilite,
  71.     weDoInhibitRecal    =    1 << weFInhibitRecal,
  72.     weDoUseTempMem        =    1 << weFUseTempMem,
  73.     weDoDrawOffscreen    =    1 << weFDrawOffscreen
  74. };
  75.  
  76. /*    values for WEFeatureFlag action parameter */
  77.  
  78. enum {
  79.     weBitTest = -1,                /* return the current setting of the specified feature */
  80.     weBitClear,                    /* disables the specified feature */
  81.     weBitSet                    /* enables the specified feature */
  82. };
  83.  
  84. /*    selectors for WEGetInfo and WESetInfo */
  85.  
  86. enum {
  87.     weClickLoop        =    'clik',        /* click loop callback */
  88.     wePort            =    'port',        /* graphics port */
  89.     weRefCon        =    'refc',        /* reference constant for use by application */
  90.     weScrollProc    =    'scrl',        /* auto-scroll callback */
  91.     weText            =    'text',        /* text handle */
  92.     weTSMDocumentID    =    'tsmd',        /* Text Services Manager document ID */
  93.     weTSMPreUpdate    =    'pre ',        /* Text Services Manager pre-update callback */
  94.     weTSMPostUpdate    =    'post'        /* Text Services Manager post-update callback */
  95. };
  96.  
  97. typedef struct WERunInfo {
  98.     long         runStart;
  99.     long         runEnd;
  100.     short         runHeight;
  101.     short         runAscent;
  102.     TextStyle     runStyle;
  103. } WERunInfo;
  104.  
  105. typedef Handle WEHandle;
  106.  
  107. /*    callback prototypes */
  108.  
  109. typedef pascal Boolean (*WEClickLoopProcPtr)(WEHandle hWE);
  110. typedef pascal void (*WEScrollProcPtr)(WEHandle hWE);
  111. typedef pascal void (*WETSMPreUpdateProcPtr)(WEHandle hWE);
  112. typedef pascal void (*WETSMPostUpdateProcPtr)(WEHandle hWE,
  113.         long fixLength, long inputAreaStart, long inputAreaEnd,
  114.         long pinRangeStart, long pinRangeEnd);
  115.  
  116. /*    WASTE public calls */
  117.  
  118. #ifdef __cplusplus
  119. extern "C" {
  120. #endif
  121.  
  122. /*    creation and destruction */
  123.  
  124. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, short flags, WEHandle *hWE);
  125. pascal void WEDispose(WEHandle hWE);
  126.  
  127. /*    getting variables */
  128.  
  129. pascal Handle WEGetText(WEHandle hWE);
  130. pascal short WEGetChar(long offset, WEHandle hWE);
  131. pascal long WEGetTextLength(WEHandle hWE);
  132. pascal long WECountLines(WEHandle hWE);
  133. pascal long WEGetHeight(long startLine, long endLine, WEHandle hWE);
  134. pascal void WEGetSelection(long *selStart, long *selEnd, WEHandle hWE);
  135. pascal void WEGetDestRect(LongRect *destRect, WEHandle hWE);
  136. pascal void WEGetViewRect(LongRect *viewRect, WEHandle hWE);
  137. pascal Boolean WEIsActive(WEHandle hWE);
  138.  
  139. /*    setting variables */
  140.  
  141. pascal void WESetSelection(long selStart, long selEnd, WEHandle hWE);
  142. pascal void WESetDestRect(const LongRect *destRect, WEHandle hWE);
  143. pascal void WESetViewRect(const LongRect *viewRect, WEHandle hWE);
  144.  
  145. /*    accessing style run information */
  146.  
  147. pascal Boolean WEContinuousStyle(short *mode, TextStyle *ts, WEHandle hWE);
  148. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEHandle hWE);
  149.  
  150. /*    converting byte offsets to screen position and vice versa */
  151.  
  152. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEHandle hWE);
  153. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEHandle hWE);
  154.  
  155. /*    finding words and lines */
  156.  
  157. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEHandle hWE);
  158. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEHandle hWE);
  159.  
  160. /*    making a copy of a text range */
  161.  
  162. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WEHandle hWE);
  163.  
  164. /*    getting and setting the alignment style */
  165.  
  166. pascal char WEGetAlignment(WEHandle hWE);
  167. pascal void WESetAlignment(char alignment, WEHandle hWE);
  168.  
  169. /*    recalculating line breaks, drawing and scrolling */
  170.  
  171. pascal OSErr WECalText(WEHandle hWE);
  172. pascal void WEUpdate(RgnHandle updateRgn, WEHandle hWE);
  173. pascal void WEScroll(long hOffset, long vOffset, WEHandle hWE);
  174. pascal void WESelView(WEHandle hWE);
  175.  
  176. /*    handling activate / deactivate events */
  177.  
  178. pascal void WEActivate(WEHandle hWE);
  179. pascal void WEDeactivate(WEHandle hWE);
  180.  
  181. /*     handling key-down events */
  182.  
  183. pascal void WEKey(short key, short modifiers, WEHandle hWE);
  184.  
  185. /*    handling mouse-down events and mouse tracking */
  186.  
  187. pascal void WEClick(Point hitPt, short modifiers, long clickTime, WEHandle hWE);
  188.  
  189. /*    adjusting the cursor shape */
  190.  
  191. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEHandle hWE);
  192.  
  193. /*    blinking the caret */
  194.  
  195. pascal void WEIdle(long *maxSleep, WEHandle hWE);
  196.  
  197. /*    modifying the text and the styles */
  198.  
  199. pascal OSErr WEInsert(const void *textPtr, long textLength, StScrpHandle hStyles, WEHandle hWE);
  200. pascal OSErr WEDelete(WEHandle hWE);
  201. pascal OSErr WESetStyle(short mode, const TextStyle *ts, WEHandle hWE);
  202. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEHandle hWE);
  203. pascal OSErr WEUseText(Handle hText, WEHandle hWE);
  204.  
  205. /*    clipboard operations */
  206.  
  207. pascal OSErr WECut(WEHandle hWE);
  208. pascal OSErr WECopy(WEHandle hWE);
  209. pascal OSErr WEPaste(WEHandle hWE);
  210.  
  211. /*    Script Manager utilities */
  212.  
  213. pascal short WECharByte(long offset, WEHandle hWE);
  214. pascal short WECharType(long offset, WEHandle hWE);
  215.  
  216. /*    Text Services Manager support */
  217.  
  218. pascal OSErr WEInstallTSMHandlers(void);
  219. pascal void WEStopInlineSession(WEHandle hWE);
  220.  
  221. /*    additional features */
  222.  
  223. pascal short WEFeatureFlag(short feature, short action, WEHandle hWE);
  224. pascal OSErr WEGetInfo(OSType selector, void *info, WEHandle hWE);
  225. pascal OSErr WESetInfo(OSType selector, const void *info, WEHandle hWE);
  226.  
  227. /*    long coordinate utilities */
  228.  
  229. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  230. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  231. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  232. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  233. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  234. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  235. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  236.  
  237. #ifdef __cplusplus
  238. }
  239. #endif
  240.  
  241. #endif //_WASTE_
  242.